<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    <head>
        <title>美业红</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1">
        <link href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
        <link href="/public/css/main.css" rel="stylesheet">
        <script type='text/javascript' src='/public/js/jquery-3.1.1.min.js'></script>
        <script type="text/javascript" src='/public/js/jquery.validate.js'></script>
        <script type="text/javascript" src='/public/js/main/main.js'></script>
        <script>
            var _hmt = _hmt || [];
            (function () {
                var hm = document.createElement("script");
                hm.src = "//hm.baidu.com/hm.js?8d43b5b5d798921b66d689f7a792e6e2";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();
        </script>
        <script type="text/javascript">
            document.domain = '<?php echo _DOMAIN_ALL_;?>';
        </script>
        <link rel="shortcut icon" type="image/ico" href="/favicon.ico">
    </head>
    <body style="background-color: #f4f4f4;">
        <div class="navigation">
            <div class='navlogo'>
            <a href='/'><img class='_navlogo' src="/public/images/logo.png"></a>
            </div>
            <div class='navson'>
                <ul class='fr'>
                <li><a href='/' class='anchor'><b>主页</b></a></li>
                <li><a href="/home/store" class='anchor'><b>店铺</b></a></li>
                <li><a href="/home/barber" class='anchor'><b>成员</b></a></li>
                <li><a href="/home/action" class='anchor'><b>活动</b></a></li>
                <li><a href="/home/order" class='anchor'><b>订单</b></a></li>
                <li><a href="/home/coupon" class='anchor'><b>优惠券</b></a></li>
                <li><a href="/home/goods" class='anchor'><b>商品</b></a></li>
                </ul>
           </div>
            <?php if($_SESSION['id']>0){?>
            <div style="float:right;padding-right:10%">你好:<span id='login_name'></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class='anchor' href='/home/passport/repassword'>修改密码</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class='anchor' href='/home/passport/logout'>退出</a></div>
            <?php }?>
        </div>
        <div style='margin-top:80px;width:100%'>
            <img class='_navlogo' src="/public/images/contentlogo.png" style='width:100%;height:100px'>
        </div>
        <div class='container'>
            <div class='_main'>
            <div class='_line'></div> 
<div class="_contro">
    <?php if($action_id>0){?>
    <b style="font-size:1.5rem;padding-right:5rem;">活动：<?php echo $action_name;?></b>
    <?php }?>
    <span style="font-size:1.5rem;padding-right:5rem;">共查询出 <span style="color:red" id='num'><?php echo $num; ?></span> 条记录</span>
    <input type="text"  placeholder="请输入订单号/手机号" value="<?php echo $search?>" id='Search' name='Search'/> 
    <input type='submit' value='查询' id='submit'/>
    <select id="store" name="store">
        <option value="0">全部店铺</option>
        <?php foreach($_store as $v){?>
        <option value='<?php echo $v['id'];?>' <?php if($store_id==$v['id']){echo "selected='selected'";}?>><?php echo $v['name'];?></option>
        <?php }?>
    </select>
    <select id="barber" name="barber">
        <option value=""  >全部成员</option>
        <?php foreach($barbers as $v){?>
        <option value="<?php echo $v['id']?>"<?php if($barber_id == $v['id']){echo 'selected="selected"';}?> ><?php echo $v['name']?></option>
        <?php }?>
    </select>            
    <select id="type" name="type">
        <option value="0" <?php if($type == 0){echo 'selected="selected"';}?> >全部状态</option>
        <option value="3" <?php if($type == 3){echo 'selected="selected"';}?> >已完成</option>
        <option value="2" <?php if($type == 2){echo 'selected="selected"';}?> >已付定金</option>
        <option value="1" <?php if($type == 1){echo 'selected="selected"';}?> >未完成</option>
    </select>
</div>
<div class="_cut"></div>
<div id='content'>
    <?php foreach($orders as $k=>$v){ ?>
    <?php if($k%3==0){?>
    <div class='row'>
        <?php }?>
        <div class='col-sm-3 col-md-4' style="margin-bottom:10px;"> 
            <div class="thumbnail" style="margin-bottom:2px;">
                <div onclick="info(<?php echo $v['id'];?>);" style="cursor:pointer" class='caption _order <?php if($v["status"]==0){echo "_not_over";}elseif($v["status"]==2 || $v["status"]==4 ){echo "_over_";}elseif($v["status"]==1){echo "_pay";}elseif($v["status"]==3){ echo "_pay_back";}?>'>
                    <div class='_order_div'>
                        <div>
                            <span>手机号：<?php echo $v['mobile']; ?></span>
                        </div>
                        <div>
                            <span>订单号：<?php echo $v['order_number'];?></span>
                        </div>
                        <div>
                            <span>发型师：<?php echo $v['barber'];?></span>
                        </div>
                        <div>
                            <span>金额：<?php echo $v['price']/100;?></span>
                        </div>
                        <div>
                            <span>项目：<?php echo $v['type'];?></span>
                        </div>
                        <div>
                            <span>类型：<?php  if($v['team_number'] ){ if($v['team']==1 && $v['model_type']==1){echo '开团';}elseif($v['team']==0 && $v['model_type']==1){echo '参团';}elseif($v['model_type']==3){ echo '公益';} }else{ echo '商城订单'; } ?></span>
                        </div>
                        <div>
                            <span>下单时间：<?php echo date('Y-m-d H:i:s',$v['create_time']);?></span>
                        </div>
                    </div>
                </div>
                <div style="padding-right:8px; height:2rem;">
                    <a href="/home/order/info?order_id=<?php echo $v['id'];?>">详情</a>
                    <?php if($v['status'] == 1 && $v['option']==true ){?>
                    &nbsp;&nbsp;&nbsp;&nbsp;<a  style="float:right;" href="/home/order/update?id=<?php echo $v['id']; ?>&store_id=<?php echo is_array($store_id)?0:$store_id;?>&barber_id=<?php echo $barber_id;?>&type=<?php echo $type;?>&Search=<?php echo urlencode($search);?>" onclick="return confirmAct();" >完成</a>
                    <?php } ?>
                </div>
            </div>

        </div>
        <?php if(($k+1)%3==0 || $orders[$k+1]['id']<1){?>
    </div>
    <?php } ?>
    <?php } ?>
</div>
<input type="hidden" value="<?php echo $action_id;?>" id="action_id">
<script type='text/javascript'>
    var number = 12;
    var nums = 0;
    function loaddata()
    {
        var type = $('#type').val();
        var search = $("#Search").val();
        var barber = $("#barber").val();
        var store_id = $("#store").val();
        if (number == -1) {
            return;
        }
        totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());

        if ($(document).height() <= totalheight)
        {
            $.ajax({url: "/home/order/append?id=<?php echo (int)$_GET['id'];?>&store_id="+store_id+"&Search=" + search + "&type=" + type + '&barber_id=' + barber + "&start=" + number, async: true, success: function (msg) {
                    if (msg == 'false') {
                        number = -1;
                        return;
                    }
                    var html = "";
                    msg = eval('(' + msg + ')');
                    $.each(msg, function (i, v) {
                        if (i % 3 == 0) {
                            html += "<div class='row'>";
                        }
                        html += "<div class='col-sm-3 col-md-4'>";
                        html += '<div class="thumbnail" style="margin-bottom:10px">';
                        html += "<div onclick='info("+v.id+");' style='cursor:pointer' class='caption _order";
                        if (v.status == 0) {
                            html += " _not_over'>";
                        } else if (v.status == 2) {
                            html += " _over_'>";
                        } else if(v.status == 1){
                            html += " _pay'>";
                        } else if(v.status == 3){
                            html += " _pay_back'>";
                        }
                        html += "<div class='_order_div'>";
                        html += "<div><span>手机号：";
                        html += v.mobile == null ? '' : v.mobile;
                        html += "</span></div>";
                        html += "<div><span>订单号：";
                        html += v.order_number == null ? '' : v.order_number;
                        html += "</span></div>";
                        html += "<span><div>发型师：";
                        html += v.barber == null ? '' : v.barber;
                        html += "</span></div>";
                        html += "<div><span>金额：";
                        html += v.price == null ? 0 : v.price;
                        html += "</span></div>";
                        html += "<div><span>项目：";
                        html += v.type == null ? 0 : v.type;
                        html += "</span></div>";
                        html += "<div><span>类型：";

                        if(v.team_number ){ 
                            if(v.team==1 && v.model_type==1){
                                html += '开团';
                            }else
                            if(v.team==0 && v.model_type==1){
                                html += '参团';
                            }else
                            if(v.model_type==3){
                             html += '公益';
                            } 
                        }else{ 
                            html += '商城订单'; 
                        } 

                       // html += v.team == 1 ? '开团' : '参团';
                        html += "</span></div>";
                        html += "<div><span>下单时间：";
                        html += v.create_time == null ? '' : v.create_time;
                        html += "</span></div></div>";
                        html += "</div><div style='padding-right:8px; height:2rem;'>";
                        html += '<a href="/home/order/info?order_id='+v.id+'">详情</a>';
                        var str = '<a  style="float:right;" href="/home/order/update?id=' + v.id + '" onclick="return confirmAct();" >完成</a>';
                        html += (v.status == 1 && v.option == 'true') ? str : '';
                        html += "</div></div></div>";
                        if ((i + 1) % 3 == 0) {
                            html += "</div>";
                        }
                        number += 1;
                    });
                    $('#content').append(html);
                }});
        }
    }

    $(window).scroll(function () {
        loaddata();
    });
    $(document).ready(function () {
        $("#type").change(function () {
            var type = $("#type").val();
            var action_id = $('#action_id').val();
            var Search = $("#Search").val();
            var barber = $("#barber").val();
            var store_id = $("#store").val();
            setTimeout(window.location.href = '/home/order/?store_id='+store_id+'&type=' + type + '&id=' + action_id + '&Search=' + Search + '&barber_id=' + barber);
        });
        $("#store").change(function(){
            var type = $("#type").val();
            var Search = $("#Search").val();
            var store_id = $("#store").val();
            setTimeout(window.location.href = '/home/order/?store_id='+store_id+'&type=' + type + '&Search=' + Search + '&barber_id=' + barber);
        });
        $("#submit").click(function () {
            var store_id = $("#store").val();
            var type = $("#type").val();
            var Search = $("#Search").val();
            var barber = $("#barber").val();
            var action_id = $('#action_id').val();
            setTimeout(window.location.href = '/home/order/?store_id='+store_id+'&type=' + type + '&id=' + action_id + '&Search=' + Search + '&barber_id=' + barber);
        });
        $("#barber").change(function () {
            var store_id = $("#store").val();
            var barber = $("#barber").val();
            var type = $("#type").val();
            var Search = $("#Search").val();
            var action_id = $('#action_id').val();
            setTimeout(window.location.href = '/home/order/?store_id='+store_id+'&type=' + type + '&id=' + action_id + '&Search=' + Search + '&barber_id=' + barber);
        });
    });


    function confirmAct()
    {
        if (confirm('确定要执行此操作吗?'))
        {
            return true;
        }
        return false;
    }
    
    function info(id){
        if(id<1){
            return;
        }
        window.open("/home/order/info?order_id="+id);
    }

</script>

</div>
</div>
<div class='_line'></div>
<div class="newfooter">
    ©2015-2017 All Rights Reserved ( 京ICP备15010043号 ) 
</div>
<div id='mask_layer' style="text-align: center;width:100%;height:100%;overflow:hidden;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#8E8E8E',endColorstr='##8E8E8E');
     background-color:rgba(255, 255, 255, 0.4);position:fixed; _position:absolute; top:0;left:0; z-index:5000;display:none ">
    <div style="padding-top: 20%"><h1><b>loading<span id="_loading"></span></b></h1></div>
</div>
</body>
<script type="text/javascript" src='/public/js/top.js'></script>
</html>